package com.example.ruleenginelearning.easyrule.rules;

import com.example.ruleenginelearning.example.model.Order;
import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Fact;
import org.jeasy.rules.annotation.Rule;

// src/main/java/com/example/ruleengine/rules/ProcessingOrderRule.java
@Rule(name = "ProcessingRule")
public class ProcessingOrderRule {

    @Condition
    public boolean isProcessing(@Fact("order") Order order) {
        return "PROCESSING".equals(order.getStatus());
    }

    @Action
    public void applyVipDiscount(@Fact("order") Order order) {
        if (order.isVip()) {
            order.applyDiscount(0.9);
            System.out.println("VIP客户享受9折优惠");
        }
        order.setStatus("SHIPPED");
    }
}